<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="/content/style.css" type="text/css" />
<title><s:text name="jsp.login.title" /></title>
</head>
<body class="mid">
    <s:url value="https://accounts.google.com/o/oauth2/auth" var="google">
        <s:param name="client_id" value="@org.tamal.Constants@GOOGLE_ID" />
        <s:param name="response_type" value="'code'" />
        <s:param name="redirect_uri" value="@org.tamal.Constants@REDIRECT_URI" />
        <s:param name="scope" value="@org.tamal.Constants@GOOGLE_SCOPE" />
        <s:param name="state" value="@org.tamal.Constants@GOOGLE_STATE" />
    </s:url>
    <s:url value="http://www.facebook.com/dialog/oauth" var="facebook">
        <s:param name="client_id" value="@org.tamal.Constants@FACEBOOK_ID" />
        <s:param name="response_type" value="'code'" />
        <s:param name="redirect_uri" value="@org.tamal.Constants@REDIRECT_URI" />
        <s:param name="scope" value="@org.tamal.Constants@FACEBOOK_SCOPE" />
        <s:param name="state" value="@org.tamal.Constants@FACEBOOK_STATE" />
    </s:url>
    <fieldset class="mid">
        <legend><s:text name="jsp.login.legend" /></legend>
        <s:if test="#session.USER == null">
            <s:form>
                <s:textfield key="jsp.login.email" maxlength="40" name="email" requiredLabel="true" required="true" />
                <s:password key="jsp.login.password" maxlength="16" name="password" requiredLabel="true" required="true" />
                <s:submit cssClass="button" key="jsp.login.login" name="submit" />
                <s:actionerror />
                <s:actionmessage />
            </s:form>
            <p style="margin: 1em 1em 0em 1em;">
                <s:text name="jsp.login.oauth" />
                <s:a href="%{google}" cssClass="button"><s:text name="jsp.login.google" /></s:a>
                <s:a href="%{facebook}" cssClass="button"><s:text name="jsp.login.facebook" /></s:a>
            </p>
        </s:if>
        <s:else>
            <p>Hi <s:property value="#session.USER.name" /> !</p>
            <a class="button" href="logout">Logout</a>
        </s:else>
    </fieldset>
</body>
</html>
